package service

import (
	"context"
	"day14/video-share/video-server/basic/handler/model"
	__ "day14/video-share/video-server/basic/proto"
)

type Server struct {
	__.UnimplementedVideoServer
}

func (s Server) CreateVideo(_ context.Context, in *__.CreateVideoReq) (*__.CreateVideoResp, error) {
	//TODO implement me
	var video model.Video

	video = model.Video{
		Title:    in.Title,
		Content:  in.Content,
		ImageUrl: in.ImageUrl,
		VideoUrl: in.VideoUrl,
	}
	err := model.CreateVideo(&video)
	if err != nil {
		return &__.CreateVideoResp{
			Code: 0,
			Msg:  "发布失败",
		}, nil
	}

	return &__.CreateVideoResp{
		Code: 200,
		Msg:  "发布成功",
	}, nil

}
